<css href="__PUBLIC__/boot-date/css/bootstrap-datetimepicker.min.css" />
<form  method="post" class="form-horizontal">
    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label"></label>
        <div class="col-md-6 col-xs-12">
            <h2>清空场次榜信息</h2>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">类型</label>
        <div class="col-md-6 col-xs-12">
            <select id="type" name="type" class="form-control">
                <option value="">请选择场次榜类型</option>
                <option value="0">1V1</option>
                <option value="1">3V3</option>
                <option value="2">5V5</option>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">榜前名次</label>
        <div class="col-md-6 col-xs-12">
            <input type="number" id="level" name="level" class="form-control" />
        </div>
    </div>

    <div>
        <div class="col-md-3 col-xs-12"></div>
        <div class="col-md-6 col-xs-12">
            <present name="errorNote">
                <div class="alert alert-danger" role="alert">
                    <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <strong>{$errorNote}</strong>
                </div>
            </present>
            <div class="form-group">
                <div class="col-md-6"><input type="reset" class="btn btn-block btn-default" value=" 清 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 空 " /></div>
                <div class="col-md-6"><button type="button" class="btn btn-block btn-info pull-right" onclick="save()"> 提 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 交 </button></div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="my-alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body" id="hint_content">
                </div>
                <div class="modal-footer">
                    <button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="save-change" data-dismiss="modal">确定</button>
                </div>
            </div>
        </div>
    </div>

</form>
<script type="text/javascript">
    function isPositiveInteger(s){
        //是否为正整数
        var re = /^[0-9]+$/ ;
        return re.test(s);
    }
    function save() {
        var type = $('#type').val();
        var level = $('#level').val();
        console.info(type);
        console.info(level);
        var title = '是否清除';
        if(type == '0'){
            title +='1v1';
        }else if(type == '1'){
            title +='3v3';
        }else if(type == '2'){
            title +='5v5';
        }else{
            $("#hint_content1").empty().append('请选择排行榜类型');
            $("#my-alert1").modal('show');
            return;
        }
        if(!isPositiveInteger(level)){
            $("#hint_content1").empty().append('请选择填写正确的榜前名次！');
            $("#my-alert1").modal('show');
            return;
        }
        title +='排行榜前'+level+'名的对战数和对战记录?';

        $("#hint_content").empty().append(title);
        $("#my-alert").modal('show');
        $('#close_btn').unbind('click');
        $('#save-change').unbind('click');
        $('#save-change').on('click', function(){
            $.ajax({
                type: "POST",
                url: '__APP__/Admin/Log/ajaxUpdateRankInfo',
                data: $('form').serialize(),
                dataType: "json",
                success: function (data) {
                    console.info(data);
                    $("#hint_content1").empty().append(data.message);
                    $("#my-alert1").modal('show');
                },
                error: function (data) {
                    $("#hint_content1").empty().append('服务器忙');
                    $("#my-alert1").modal('show');
                }
            });
        });
    }
    function jump() {
        window.location = '__URL__/';
    }
</script>